#! /usr/bin/pytohn
# -*- coding: utf-8 -*- 


import os
import sys
import time

from msg_consumer import *
import app_global

from db_ctrl import *
from db_conf import *
from plate_model import *


ONE_DAY_IN_SECONDS = 60 * 60 * 24

log = app_global.gLog

def app_run():
    
    db = CDBProcessor() #data process: save, select
    
    db.connect()
    model = CFlattenModel()
    consumer = CMsgConsumer(db,model)
    consumer.start()
    
    try:
        while True:
            time.sleep(ONE_DAY_IN_SECONDS)
    except KeyboardInterrupt:
            app_global.SYS_RUN = False
    
    consumer.join()


if __name__ =="__main__":
   app_run()
